const path = require('path');

//在文件顶部增加
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode:"development",
    devtool: 'inline-source-map',
    entry:"./src/main.js",
    output:{
       path: path.resolve(__dirname, 'dist'),
       filename:"bundle.js"
    },
    module:{
        rules: [
            {
                test: require.resolve('jquery'),
                use: [
                    {
                        loader: 'expose-loader',
                        options: '$'
                    },
                    {
                        loader: 'expose-loader',
                        options: 'jQuery'
                    }
                ]
            },
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['env']
                        }
                }
            },
            {
                test: /\.css$/,
                use: ['style-loader','css-loader']
            },
            {
				test: /\.(html)$/,
				use: {
					loader: 'html-loader',
					options: {
						attrs: ['img:src']
					}
				}
			},
            {
                test: /\.(png|jpg|gif)$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 8192,
                            name: 'img/[hash:8].[name].[ext]'
                        }
                    }
                ]
            },
            {
				test:/\.(mp4)$/,
				use:[
					{
						loader:"url-loader",
						options:{
							limit:10000,
							name:'video/[name].[ext]'
						}
					}
				]
			}
        ]
    },
    //然后再增加
    plugins: [
        new HtmlWebpackPlugin({
            title:"webpack自动演示系统",
            template:"./src/index.html"
        })
    ]
}